/**
 * @Date: 2022-04-08 12:48:48
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-11 16:36:43
 * @FilePath: \weibo-api\utils\cryp.js
 * @Description: 密码加密
 */
const crypto = require("crypto");

//密钥
const PASSWORD_SCRET_KEY = require("../conf/db");
//md5加密
function md5(content) {
  let md5 = crypto.createHash("md5");
  //变成16进制
  return md5.update(content).digest("hex");
}
//加密函数
function genPassword(password) {
  const str = `password=${password}&key=${PASSWORD_SCRET_KEY}`;
  return md5(str);
}
module.exports = {
  genPassword,
};
